package com.CMS.server.dao;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import com.CMS.server.domain.Language;

public class LanguageDao extends BaseDao<Language>{

	public Language getLanguageActive(){
		EntityManager em = entityManager();
		Language l = null;
		try{
			Query q = em.createQuery("select e from Language e where e.active = 1");
			l = (Language) q.getSingleResult();
		}
		finally{
			em.close();
		}
		
		return l;
	}
	
	public Language getLanguageByValue(String value){
		EntityManager em = entityManager();
		Language l = null;
		try{
			Query q = em.createQuery("select e from Language e where e.value = ?1");
			q.setParameter(1, value);
			l = (Language) q.getSingleResult();
		}
		finally{
			em.close();
		}
		
		return l;
	}
}
